
//
//  MKPopViewController.swift
//  101weibo
//
//  Created by 劢克科技 on 2019/1/18.
//  Copyright © 2019 劢克科技. All rights reserved.
//

import UIKit
import SnapKit

class MKPopViewController: UIViewController {
    
    private lazy var bgImage = UIImageView()
    private lazy var tableV = UITableView()

    override func viewDidLoad() {
        super.viewDidLoad()

        setupUI()
    }
}

//MARK: - UI
extension MKPopViewController {
    func setupUI() {
        
        view.addSubview(bgImage)
        view.addSubview(tableV)

        tableV.snp.makeConstraints { (make) in
            make.edges.equalTo(view).inset(UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20))
        }
        
        bgImage.snp.makeConstraints { (make) -> Void in
            make.edges.equalTo(view).inset(UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0))
        }
        view.backgroundColor = UIColor.clear
        
        setResiableImage()
    }
    
    func setResiableImage() {
        guard let image = UIImage(named: "popover_background") else {
            return
        }
        let imageHeight = image.size.height
        let resiableImage = image.stretchableImage(withLeftCapWidth: 0, topCapHeight: Int(imageHeight / 2))
        bgImage.image = resiableImage
    }
}
